package com.hongyuan.sellfitness.ui.message.view_mode;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;

import com.hongyuan.mvvmhabitx.binding.command.BindingAction;
import com.hongyuan.mvvmhabitx.binding.command.BindingCommand;
import com.hongyuan.sellfitness.base.Constants;
import com.hongyuan.sellfitness.base.ItemViewModel;
import com.hongyuan.sellfitness.ui.message.beans.MessageCommentaryBean;
import com.hongyuan.sellfitness.ui.message.beans.MessageLetterBean;


public class MessageCommentaryItemViewModel extends ItemViewModel<MessageCommentaryViewModel> {

    public ObservableField<MessageCommentaryBean.ListBean> entity = new ObservableField<>();

    public MessageCommentaryItemViewModel(@NonNull MessageCommentaryViewModel viewModel, MessageCommentaryBean.ListBean bean) {
        super(viewModel);
        entity.set(bean);
    }

    public int getPosition() {
        return viewModel.getItemPosition(this);
    }

    //条目的点击事件
    public BindingCommand itemClick = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            viewModel.itemClick(MessageCommentaryItemViewModel.this);

            viewModel.setParams("msg_id",String.valueOf(entity.get().getMsg_id()));
            viewModel.requestData(Constants.UPATE_MSG_READ);
        }
    });
}
